<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Core\Controller;
use Think\Controller;

/**
 * Class PublicController  公共控制器
 * @package Core\Controller
 * @author:xjw129xjt(肖骏涛) xjt@ourstu.com
 */
class PublicController extends Controller
{

    /**关注某人
     * @param int $uid
     * @auth 陈一枭
     */
    public function follow($uid = 0)
    {
        if(!is_login()){
            $this->ajaxReturn(array('status' => 0,'info'=>'请登陆'));
        }

        if (D('Follow')->follow($uid)) {
            $this->ajaxReturn(array('status' => 1,'info'=>'关注成功'));
        } else {
            $this->ajaxReturn(array('status' => 0,'info'=>'关注失败'));
        }
    }

    /**取消对某人的关注
     * @param int $uid
     * @auth 陈一枭
     */
    public function unfollow($uid = 0)
    {
        if(!is_login()){
            $this->ajaxReturn(array('status' => 0,'info'=>'请登陆'));
        }

        if (D('Follow')->unfollow($uid)) {
            $this->ajaxReturn(array('status' => 1,'info'=>'取消关注成功'));
        } else {
            $this->ajaxReturn(array('status' => 0,'info'=>'取消关注失败'));
        }
    }

}
